package com.carbon.system.controller;

import com.carbon.domain.common.ApiResult;
import com.carbon.domain.mq.entity.AddTradingAccountApproval;
import com.carbon.domain.mq.entity.AssetUploadApproval;
import com.carbon.domain.mq.entity.ProjectApproval;
import com.carbon.domain.mq.entity.QuotaApproval;
import com.carbon.system.common.BaseController;
import com.carbon.system.service.CarbonApprovalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 碳排放审批控制器，负责处理各种碳排放相关审批请求
 */
@Slf4j
@RestController
@RequestMapping("/approval")
@Api(value = "审批模块", tags = {"审批模块"})
public class CarbonApprovalController extends BaseController {
    @Resource
    private CarbonApprovalService carbonApprovalService;

    /**
     * 添加资产上传审批
     *
     * @param approval 资产上传审批信息
     * @return 审批结果
     */
    @PostMapping("/addAssetsApproval")
    @ApiOperation(value = "添加资产上传审批")
    public ApiResult<Boolean> addAssetsApproval(@Valid @RequestBody AssetUploadApproval approval) {
        carbonApprovalService.addAssetsApproval(approval);
        return ApiResult.ok();
    }

    /**
     * 添加交易账户审批
     *
     * @param approval 交易账户审批信息
     * @return 审批结果
     */
    @PostMapping("/addTradeAccountApproval")
    @ApiOperation(value = "添加交易账户审批")
    public ApiResult<Boolean> addTradeAccountApproval(@Valid @RequestBody AddTradingAccountApproval approval) {
        carbonApprovalService.addTradeAccountApproval(approval);
        return ApiResult.ok();
    }

    /**
     * 添加项目立项审批
     *
     * @param approval 项目立项审批信息
     * @return 审批结果
     */
    @PostMapping("/addProjectApproval")
    @ApiOperation(value = "添加项目立项审批")
    public ApiResult<Boolean> addProjectApproval(@Valid @RequestBody ProjectApproval approval) {
        carbonApprovalService.addProjectApproval(approval);
        return ApiResult.ok();
    }

    /**
     * 添加项目额度审批
     *
     * @param approval 项目额度审批信息
     * @return 审批结果
     */
    @PostMapping("/addQuotaApproval")
    @ApiOperation(value = "添加项目立项审批")
    public ApiResult<Boolean> addQuotaApproval(@Valid @RequestBody QuotaApproval approval) {
        carbonApprovalService.addQuotaApproval(approval);
        return ApiResult.ok();
    }

}

